﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MountSilverLibraryRemake
{
    public partial class AddAndModifyDialogYellow : Form
    {
        TrueBook book;
        public AddAndModifyDialogYellow(ref TrueBook book)
        {
            InitializeComponent();
            this.book = book;
            bookname.Text = book.name;
            bookversion.Text = book.version;
            bookISBN.Text = book.ISBN;
            bookauthor.Text = book.author;
            bookrepublic.Text = book.republic;
            bookstorage.Text = book.storage.ToString();
            bookbaseprice.Text = book.baseprice.ToString();
            bookdiscount.Text = book.discount.ToString();
            bookfinalprice.Text = book.discount.ToString();
        }

        private void confirm_Click(object sender, EventArgs e)
        {
            book.name = bookname.Text;
            book.version = bookversion.Text;
            book.ISBN = bookISBN.Text;
            book.author = bookauthor.Text;
            book.republic = bookrepublic.Text;
            try
            {
                book.storage = Convert.ToInt32(bookstorage.Text);
                book.baseprice = Convert.ToDouble(bookbaseprice.Text);
                book.discount = Convert.ToDouble(bookdiscount.Text);
                book.finalprice = Convert.ToDouble(bookfinalprice.Text);
                book.isTrueBook = true;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.StackTrace);
            }
            this.Close();
         }
    }
}
